From: Colin Walters Date: Tue, 23 May 2017 19:13:08 +0000 (-0400) Subject: repo/commit: Don't renormalize trusted metadata X-Git-Tag: archive/raspbian/2022.1-3+rpi1~1^2~4^2~36^2~54 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=ec1964dd4416e255d41d590e08bc247484f1f304;p=ostree.git repo/commit: Don't renormalize trusted metadata As the comment in the code says; in the expected checksum case, the caller really has to have a normal form already. Closes: #881 Approved by: jlebon --- diff --git a/src/libostree/ostree-repo-commit.c b/src/libostree/ostree-repo-commit.c index fde25db5..226ddcda 100644 --- a/src/libostree/ostree-repo-commit.c +++ b/src/libostree/ostree-repo-commit.c @@ -1511,6 +1511,7 @@ ostree_repo_write_metadata (OstreeRepo *self, GCancellable *cancellable, GError **error) { + g_autoptr(GVariant) normalized = NULL; /* First, if we have an expected checksum, see if we already have this * object. This mirrors the same logic in ostree_repo_write_content(). */ @@ -1526,9 +1527,17 @@ ostree_repo_write_metadata (OstreeRepo *self, *out_csum = ostree_checksum_to_bytes (expected_checksum); return TRUE; } + /* If the caller is giving us an expected checksum, the object really has + * to be normalized already. Otherwise, how would they know the checksum? + * There's no sense in redoing it. + */ + normalized = g_variant_ref (object); + } + else + { + normalized = g_variant_get_normal_form (object); } - g_autoptr(GVariant) normalized = g_variant_get_normal_form (object); if (!metadata_size_valid (objtype, g_variant_get_size (normalized), error)) return FALSE;